﻿<div class="zTable <@=setting.usePager?'pager':''@>">
    <table class="zTable-table" style="text-align: <@=setting.tableAlign@>;">
        <thead>
        <tr>
            <@if(setting.showSerialId){@>
            <th class="serial-id">序号</th>
            <@}@>
            <@if(setting.head.length>0){@>
            <@$.each(setting.head,function(i,n){@>
            <th><@=n.name@></th>
            <@})@>
            <@}else if(setting.zColumns.length>0){@>
            <@for(k in setting.zColumns[0]){@>
            <th><@=k@></th>
            <@}@>
            <@}@>
            <@if(setting.operation.length>0){@>
            <th class="zTable-operation-th">操作</th>
            <@}@>
        </tr>
        </thead>
        <tbody>
        <@if(setting.zColumns.length>0){@>
        <@$.each(setting.zColumns,function(i,n){@>
        <@ var attrStr = "";$.each(setting.rowData,function(k,l){
        attrStr = attrStr +" "+l.attrName + "='"+n[l.attrKey]+"'";
        })@>
        <tr <@=attrStr@> class="zTable-body-tr">
        <@if(setting.showSerialId){@>
        <td class="serial-id">&nbsp;&nbsp;<@=i+1@>&nbsp;&nbsp;</td>
        <@}@>
        <@if(setting.head.length>0){@>
        <@$.each(setting.head,function(j,m){@>
        <@if(m.dateFormat){@>
        <@if(isEmpty(n[m.key])){@>
        <td nowrap="nowrap">-</td>
        <@}else if(m.dateFormat == "date"){@>
        <td nowrap="nowrap"><@=new Date(n[m.key]).zTableFormat("yyyy-MM-dd")@></td>
        <@}else if(m.dateFormat == "time"){@>
        <td nowrap="nowrap"><@=new Date(n[m.key]).zTableFormat("yyyy-MM-dd HH:mm:ss")@></td>
        <@}@>
        <@}else{@>
        <td nowrap="nowrap"><@=(isEmpty(n[m.key])?"":n[m.key])@></td>
        <@}@>
        <@})@>
        <@}else{@>
        <@for(k in n){@>
        <@if(typeof n[k] == 'object'){@>
        <td nowrap="nowrap"><@='[Object]'@></td>
        <@}else{@>
        <td nowrap="nowrap"><@=(isEmpty(n[k])?"-":n[m.key])@></td>
        <@}@>
        <@}@>
        <@}@>
        <@if(setting.operation.length>0){@>
        <td>
            <@$.each(setting.operation,function(j,m){@>
            <div class="zTable-operation <@=m.className@>"><@=m.name@></div>
            <@})@>
        </td>
        <@}@>
        </tr>
        <@})@>
        <@}else{@>
        <@var cols = setting.showSerialId ? (setting.head.length+1) : setting.head.length@>
        <tr><td colspan="<@=cols+setting.operation.length@>">暂无数据</td></tr>
        <@}@>
        </tbody>
    </table>
</div>
<@if(setting.usePager){@>
<div class="zTable-pager">
    <div class="zTable-page-num">
        <@ var pageInfo = setting.pageInfo; @>
        <@ var curPage = pageInfo.pageNum; @>
        <@ var totalPage = pageInfo.totalPage; @>
        <div class="zTable-pageBtn zTable-pageBefore">上一页</div>
        <@for(var i=1;i<=5;i++){ @>
        <@if(curPage<4){@>
        <@ if(i>totalPage){ break;}@>
        <div class="zTable-pageBtn zTable-page-block <@=curPage==i?'active':''@>"><@=i@></div>
        <@}else if(curPage>=4 && totalPage>=curPage+2){@>
        <div class="zTable-pageBtn zTable-page-block <@=i==3?'active':''@>"><@=curPage+(i-3)@></div>
        <@}else{@>
        <div class="zTable-pageBtn zTable-page-block <@=5-(totalPage-curPage)==i?'active':''@>"><@=totalPage-(5-i)@></div>
        <@}@>
        <@}@>
        <div class="zTable-pageBtn zTable-pageNext">下一页</div>
    </div>
    <span>
             共<span><@=pageInfo.totalPage@></span>页
        </span>
    <span>
            <@var totalRecords = pageInfo.totalRecords == 0 ? setting.zColumns.length : pageInfo.totalRecords;@>
            <span><@=totalRecords@></span>条记录
        </span>
</div>
<@}@>